﻿using System;
using System.Windows.Forms;

namespace BrokenDelusionMod.Install
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Install_Click(object sender, EventArgs e)
        {
            string path;
            Inject inject;
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Assembly文件|Assembly-CSharp.dll";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog.FileName;
                inject = new Inject(path);
                if (inject.Install())
                {
                    inject.InjectFunTail("GameManager", "Awake", "Mod", "StartCall");
                    inject.InjectFunHead("VnManager", "ExecuteCommand", "Mod", "OutCommand");
                    inject.InjectFunHead("ScreenClickEffect", "Update", "Log", "Update");
                    //inject.InjectFunTail("VnManager", "Awake", "Mod", "AddChoice");
                    inject.InstallEnd();
                }
            }
        }

        public void Log(string log)
        {
            LogInfo.Items.Add(log);
        }
        public void LogClear()
        {
            LogInfo.Items.Clear();
        }

        private void UnInstall_Click(object sender, EventArgs e)
        {
            string path;
            Inject inject;
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Assembly文件|Assembly-CSharp.dll";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                path = openFileDialog.FileName;
                inject = new Inject(path);
                inject.Uninstall();
            }
        }
    }
}
